package com.cwvs.cat.adapter;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cwvs.cat.R;
import com.cwvs.cat.bean.MyMessageBean;

public class FoundMyMessageAdapter extends BaseAdapter {

	private List<MyMessageBean> list_contact;
	private LayoutInflater inflater;

	public FoundMyMessageAdapter() {
		// TODO Auto-generated constructor stub
	}

	public FoundMyMessageAdapter(Activity ac, List<MyMessageBean> list) {
		// TODO Auto-generated constructor stub
		this.inflater = LayoutInflater.from(ac);
		this.list_contact = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list_contact.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list_contact.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewholder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_list_found_my_message,
					null);
			viewholder = new ViewHolder();
			viewholder.txt_my_message_name = (TextView) convertView
					.findViewById(R.id.txt_my_message_name);
			viewholder.img_my_message_logo = (ImageView) convertView
					.findViewById(R.id.img_my_message_logo);
			convertView.setTag(viewholder);

		} else {
			viewholder = (ViewHolder) convertView.getTag();
		}
		viewholder.txt_my_message_name.setText(list_contact.get(position)
				.getMsgName());
		viewholder.img_my_message_logo.setBackgroundResource(list_contact.get(position)
				.getMsgLogo());
		return convertView;
	}

	class ViewHolder {
		TextView txt_my_message_name, txt_my_message_time;
		ImageView img_my_message_logo;

	}

}
